const Router = require('koa-router')
const router = new Router()
router.prefix('/api/home/option')

const { //控制器
  checkOptionExist, findList, create,
  update, findById, delete: del,
  uploadImg, uploadVoice
} = require('../controllers/home')

const { //中间件
  auth, checkUserAuthorization
} = require('../middleware/index')

router.get('/', findList) //获取页面选项列表

router.get('/:id', checkOptionExist, findById) //获取指定页面选项详情

router.put('/:id/img', auth, checkUserAuthorization, checkOptionExist, uploadImg) // 上传图片

router.put('/:id/voice', auth, checkUserAuthorization, checkOptionExist, uploadVoice) // 上传音频

router.post('/', auth, checkUserAuthorization, create) //新建页面选项

router.patch('/:id', auth, checkUserAuthorization, checkOptionExist, update) //更新页面选项

router.delete('/:id', auth, checkUserAuthorization, checkOptionExist, del) //删除页面选项

module.exports = router
